﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Circo.Framework.BusinessLogic.Views.Filters;
using SC.eWedding.BusinessLogic.Views;
using SC.eWedding.BusinessLogic.Handlers;
using System.Text;
using SC.eWedding.BusinessLogic.Mail;

public partial class Proveedor_InicioSesion : System.Web.UI.Page
{
    #region Eventos

    protected void lbRegistrar_Click(object sender, EventArgs e)
    {
        Response.Redirect("Registro.aspx");
    }

    protected void btnRecuperar_Click(object sender, EventArgs e)
    {
        //EMail.MandarMail("andreabo@m3sa.com", "Hola", "Chau");
        List<ViewFilter> filtros = new List<ViewFilter>();

        filtros.Add(new ViewCommonFilter("Mail", txtMail.Text));

        List<ProveedorView> listProv = ProveedorHandler.FindBy(filtros);
        if (listProv.Count != 0)
        {
            EMail.MandarMail("andreabo@m3sa.com", "Hola", "Chau");
        }
        else
        {
            if (!Page.ClientScript.IsStartupScriptRegistered("script_Error"))
            {
                StringBuilder script = new StringBuilder();

                script.Append("<script language=\"jscript\">\n");
                script.Append("   alert('El mail ingresado es incorrecto!!');\n");
                script.Append("</script>\n");

                Page.ClientScript.RegisterStartupScript(GetType(), "script_Error", script.ToString());
            }
        }
    }

    protected void lblRecupUsuario_Click(object sender, EventArgs e)
    {
        tInicioSesion.Visible = false;
        tInicioSesion.Disabled = true;

        tRecuperar.Visible = true;
        tRecuperar.Disabled = false;
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            tInicioSesion.Visible = true;
            tInicioSesion.Disabled = false;

            tRecuperar.Visible = false;
            tRecuperar.Disabled = true;
        }
    }

    #endregion
    
}
